
/**
* @module map
* @author: Hjava
* @description: 根据Map定义规范来实现一个简单的Map，由于值只能为string，因此不考虑分开存储。
* @since: 2018-07-23 15:19:06
*/
Object.defineProperty(exports, "__esModule", { value: true });
var Map = /** @class */ (function () {
    function Map(data) {
        this._map = {};
        this.size = 0;
        if (Array.isArray(data)) {
            for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
                var i = data_1[_i];
                this.set(i[0], i[1]);
            }
            this.size = Object.keys(this._map).length;
        }
    }
    Map.prototype.has = function (key) {
        return Object.prototype.hasOwnProperty.call(this._map, key);
    };
    Map.prototype.get = function (key) {
        if (this.has(key)) {
            return this._map[key];
        }
        return void 0;
    };
    Map.prototype.set = function (key, value) {
        this._map[key] = value;
        this.size = Object.keys(this._map).length;
    };
    Map.prototype.setNoSize = function (key, value) {
        this._map[key] = value;
    };
    Map.prototype.updateSize = function () {
        this.size = Object.keys(this._map).length;
    };
    Map.prototype.delete = function (key) {
        if (this.has(key)) {
            delete this._map[key];
            this.size = Object.keys(this._map).length;
        }
        return true;
    };
    Map.prototype.keys = function () {
        return Object.keys(this._map);
    };
    Map.prototype.values = function () {
        var _this = this;
        return this.keys().map(function (key) {
            return _this._map[key];
        });
    };
    Map.prototype.entries = function () {
        var keys = this.keys();
        var entries = [];
        for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
            var i = keys_1[_i];
            entries.push([i, this.get(i)]);
        }
        return entries;
    };
    return Map;
}());
exports.default = Map;


//# sourceURL=webpack://MTDX/./src/extra/utils/map.ts?